<?php
namespace App\Http\Controllers\Api;

use App\Http\Model\Hint;
use App\Model\AdminIp;
use App\Model\Number;
use App\Model\OperationLogs;
use Illuminate\Http\Request;

class GameController extends BaseController
{
    protected $model = null;

    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new AdminIp();
    }

    //后台ip白名单列表
    public function poolList(Request $request, Number $number){
        $data = $request->all();
        if(empty($data['game_id']) || empty($data['uuid'])) {
            $this->toJson(self::PARAM_ERROR);
        }

        $user_info = $number->getInfoByUserId($data['uuid']);
        if (empty($user_info)) {
            return $this->toJson(self::ERROR, [], '用户不存在');
        }
        $data['user_id'] = $user_info['user_id'];
        $logData = [
            'game_id' => $data['game_id'],
            'user_id' => $data['user_id'],
        ];
        $url = getKkaudioApiUrl();
        $res = curl_request($url.'/inner/game/poolListV2',$data,'urlencoded','GET');
        if ($res['code'] == 0) {
            OperationLogs::createData($request, OperationLogs::SYSTEM, "快捷查询", $logData);
            return $this->toJson(self::SUCCESS, $res['data']);
        }
        return $this->toJson(self::ERROR, [], $res['msg']??'失败');

    }


    public function setMagnWinner(Request $request) {
        $params = $request->all();
        if(empty($params['winner'])) {
            $this->toJson(self::PARAM_ERROR);
        }

        $admin = $this->user;

        $data['winner'] = $params['winner'];
        $data['admin_id'] = $admin['id'];
        $url = getKkaudioActivityUrl();
        $res = curl_request($url.'/inner/grasslandSheep/setGSWSummerConfigV2',$data,'urlencoded','GET');
        if ($res['code'] == 0) {
            OperationLogs::createData($request, OperationLogs::SYSTEM, "倍率设置", $data);
            return $this->toJson(self::SUCCESS, $res['data']);
        }
        return $this->toJson(self::ERROR, [], $res['msg']??'失败');
    }



}
